import { Descriptions as AntDescriptions } from 'antd'
import { UnknownText } from '../UnknownText'

const { Item } = AntDescriptions
export type DescriptionsItemProps = React.ComponentProps<typeof Item>
interface DescriptionsProps extends React.ComponentProps<typeof AntDescriptions> {
  items: Array<DescriptionsItemProps>
}

export const Descriptions = ({ items, ...restProps }: DescriptionsProps) => {
  return (
    <AntDescriptions {...restProps}>
      {items.map(itemProps => (
        <Item {...itemProps} key={itemProps.label?.toString()} children={itemProps.children || <UnknownText />} />
      ))}
    </AntDescriptions>
  )
}
